package com.wxjfkg.config;

import java.util.concurrent.TimeUnit;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.stereotype.Component;

import com.wxjfkg.ActivitiServiceApplycation;


/**
 * 应用服务器启动参数配置
 * Created by zhangjinye on 2016/4/21.
 */
@Component
@SpringBootApplication
public class SpringBootServletInitializer implements EmbeddedServletContainerCustomizer {

    @Value("${server.port}")
    private Integer port;

    @Value("${server.sessionTimeout}")
    private Integer sessionTimeout;

    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(ActivitiServiceApplycation.class);
    }


    public void customize(ConfigurableEmbeddedServletContainer configurableEmbeddedServletContainer) {
        configurableEmbeddedServletContainer.setPort(port);//设置启动端口号
        configurableEmbeddedServletContainer.setSessionTimeout(sessionTimeout, TimeUnit.SECONDS);//会话超时时间
    }
}
